//2019-3-6
//幼小清
$(function(){

    $(document).scroll(function() {
        let Goal = $('.RollingGoal');
         GoalH = Goal.height()*0.7
        let scroH = $(document).scrollTop();
        if(scroH > GoalH){
            Goal.addClass('on')
            Goal.find('.CenterBackBtn img').attr('src','images/return_black.png')
            Goal.find('.CenterHeaderSetting img').attr('src','images/setting_black.png')
        }else{
            Goal.removeClass('on')
            Goal.find('.CenterBackBtn img').attr('src','images/return.png')
            Goal.find('.CenterHeaderSetting img').attr('src','images/setting.png')
        }
    });

    var unSelected = "#ccc";
    var selected = "#000";
    $("select").css("color", unSelected);
    $("option").css("color", selected);
    $("select").change(function () {
        var selItem = $(this).val();
        if (selItem == $(this).find('option:first').val()) {
            $(this).css("color", unSelected);
        } else {
            $(this).css("color", selected);
        }
    });

    $(document).on('click','.TabUl li',function(){
        let that = $(this)
        that.siblings().removeClass("on");
        that.addClass("on");
        let index = that.index()+1
        let div = that.parents('.TabUl').siblings('.TabDivList')
        div.find('.TabDiv').removeClass("on");
        div.find('.TabDiv:nth-child('+index +')').addClass("on");

    })


});
//图片获取显示
function  ShowImage(){
    $("input[type='file']").on("change",function(){
        var _thisId = $(this).attr("id");
        var objUrl = getObjectURL(this.files[0]) ; //获取图片的路径，该路径不是图片在本地的路径
        if (objUrl) {
            $("."+_thisId).attr("src", objUrl) ; //将图片路径存入src中，显示出图片
        }
    });
    //建立一個可存取到該file的url
    function getObjectURL(file) {
        var url = null ;
        if (window.createObjectURL!=undefined) { // basic
            url = window.createObjectURL(file) ;
        } else if (window.URL!=undefined) { // mozilla(firefox)
            url = window.URL.createObjectURL(file) ;
        } else if (window.webkitURL!=undefined) { // webkit or chrome
            url = window.webkitURL.createObjectURL(file) ;
        }
        return url ;
    }
}

